<?xml version="1.0" encoding="UTF-8"?>
<project  basedir=".." default="default" name="WrenchDb.Releases-impl">
    <target name="BuildCAWar">
    
        <property name="wdb.webname" value="WrenchDb.Web.AppContainer.war"/>
        <tstamp>
            <format property="releasenumber" pattern="yyyyMMdd"/>
        </tstamp>
        <property name="wdb.base" value="${basedir}/releases/archive/${releasenumber}"/>
        <property name="wdb.caname" value="WrenchDb.CentralAdmin.Web" />
        <property name="wdb.tmpfolder" value="${wdb.base}/_tmp_empty"/>
        <property name="wdb.templatewar" value="${wdb.base}/WrenchDb.Empty.Web.war"/>
        <property name="wdb.settings" value="${wdb.tmpfolder}/WEB-INF/wdb_db.properties" />   
        <property name="wdb.contextxml" value="${wdb.tmpfolder}/META-INF/context.xml" />   
        
        <mkdir dir="${wdb.tmpfolder}"/>
        <delete dir="${wdb.tmpfolder}"/>
        
        <unwar src="${basedir}/dist/${wdb.webname}"
                dest="${wdb.tmpfolder}">
             <patternset>
                 <include name="**/*.*"/>
                 
             </patternset>
         </unwar>
         
         <!-- creo le cartelle per il repository dei deploy -->
         <mkdir dir="${wdb.tmpfolder}/WEB-INF/reporoot/1.0/releases"/>
         <mkdir dir="${wdb.tmpfolder}/WEB-INF/reporoot/1.0/templates"/>
         <mkdir dir="${wdb.tmpfolder}/WEB-INF/reporoot/temp"/>
         <echo message="do not remove this folder" output="${wdb.tmpfolder}/WEB-INF/reporoot/1.0/releases/readme.txt"/>
         <echo message="do not remove this folder. Jar files inside are needed to prerform deploy actions" output="${wdb.tmpfolder}/WEB-INF/reporoot/1.0/templates/readme.txt"/>
         <echo message="this is a temporary folder. please empty it periodically." output="${wdb.tmpfolder}/WEB-INF/reporoot/temp/readme.txt"/>
         <copy file="${wdb.templatewar}" tofile="${wdb.tmpfolder}/WEB-INF/reporoot/1.0/templates/WrenchDb.Empty.Web.war" />
         
         
        
         <!-- set default CA settings values -->
         <delete file="${wdb.settings}" />
         <echo message="hibernate.connection.driver_class=org.postgresql.Driver${line.separator}" append="true" output="${wdb.settings}" />
         <echo message="hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect${line.separator}" append="true" output="${wdb.settings}" />
         <echo message="hibernate.connection.url=?? set your value here ??${line.separator}" append="true" output="${wdb.settings}" />
         <echo message=" hibernate.connection.username=?? set your value here ??${line.separator}"  append="true" output="${wdb.settings}" />
         <echo message="hibernate.connection.password=?? set your value here ??${line.separator}" append="true" output="${wdb.settings}" />
         <echo message="wdb.entitypackages=WrenchDb.DAL.Entities${line.separator}" append="true" output="${wdb.settings}" />
         <echo message="application_id=1${line.separator}" append="true" output="${wdb.settings}" />
         <echo message="repoRoot=WEB-INF/reporoot/${line.separator}" append="true" output="${wdb.settings}" />
          <!-- set default CONTEXT.xml -->
         
         <delete file="${wdb.contextxml}" />
         <echo   output="${wdb.contextxml}" message='&lt;?xml version="1.0" encoding="UTF-8"?&gt;${line.separator}' append="true" />
         <echo   output="${wdb.contextxml}" message='&lt;Context antiJARLocking="true" path="/${wdb.caname}" /&gt;${line.separator}' append="true" />
         
         <!-- controllo e forzatura inclusione libreria CA -->
         <zip   basedir="${wdb.tmpfolder}"      destfile="${wdb.base}/${wdb.caname}.war">
             <patternset>
                 <include name="**/*.*"/>
             </patternset>
         </zip>
         <delete dir="${wdb.tmpfolder}"/>
    </target>
</project>

